//
//  ScrollViewTableCell.m
//  Tang
//
//  Created by 352324497@qq.com on 15/12/4.
//  Copyright © 2015年 352324497@qq.com. All rights reserved.
//

#import "ScrollViewTableCell.h"

@implementation ScrollViewTableCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        CGFloat height = KWidth * 330 / 620;
        self.picImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KWidth, height)];
        [self.contentView addSubview:_picImageView];
        
        self.titleView = [[UIView alloc]initWithFrame:CGRectMake(0, height, KWidth, 80 * Kx6)];
        self.titleView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_titleView];
        
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 10 * Kx6, KWidth, 30 * Kx6)];
        //        self.titleLabel.backgroundColor = [UIColor redColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.textColor = [UIColor darkGrayColor];
        self.titleLabel.font = [UIFont systemFontOfSize:18 * Kx6];
        [self.titleView addSubview:_titleLabel];
        
        self.likeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(KWidth / 2 - 20 * Kx6, 40 * Kx6, 20 * Kx6, 20 * Kx6)];
        self.likeImageView.image = [UIImage imageNamed:@"like"];
        [self.titleView addSubview:_likeImageView];
        
        self.likesLabel = [[UILabel alloc]initWithFrame:CGRectMake(KWidth / 2, 40 * Kx6, KWidth / 2, 20 * Kx6)];
        //        self.likesLabel.backgroundColor = [UIColor greenColor];
        self.likesLabel.textColor = [UIColor lightGrayColor];
        self.likesLabel.font = [UIFont systemFontOfSize:14 * Kx6];
        [self.titleView addSubview:_likesLabel];
    }
    return self;
}

-(void)setModel:(ScrollViewCellModel *)model
{
    _model = model;
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"PCe"]];
    self.titleLabel.text = model.title;
    self.likesLabel.text = model.likes;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
